﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace BloomsburyBanHang.DAO
{
    public class NhaMoGioiDAO
    {
        private string tenNhaMoGioi;

        public string TenNhaMoGioi
        {
            get { return tenNhaMoGioi; }
            set { tenNhaMoGioi = value; }
        }
        private string uRL;

        public string URL
        {
            get { return uRL; }
            set { uRL = value; }
        }
        private string tenService;

        public string TenService
        {
            get { return tenService; }
            set { tenService = value; }
        }
        private string tenHamLogin;

        public string TenHamLogin
        {
            get { return tenHamLogin; }
            set { tenHamLogin = value; }
        }
        private string tenHamTranfer;

        public string TenHamTranfer
        {
            get { return tenHamTranfer; }
            set { tenHamTranfer = value; }
        }

        public static NHA_MO_GIOI layNMGtheoten(string ten) {
            NhaBanLeDataContext db = new NhaBanLeDataContext();

            var query = from hd in db.NHA_MO_GIOIs
                        where hd.TenNhaMoGioi == ten
                        select hd;
            NHA_MO_GIOI hoadon = query.First<NHA_MO_GIOI>();
            return hoadon;
        }
        public static int ThemNhaMoGioi(string tenNhaMoGioi,string URL,string tenservice,string tenhamlogin,string tenhamTranfer)
        {
            int kq = -1;
            NhaBanLeDataContext db = new NhaBanLeDataContext();
            System.Data.Linq.Table<NHA_MO_GIOI> table = db.GetTable<NHA_MO_GIOI>();
            try
            {
                NHA_MO_GIOI sp = new NHA_MO_GIOI();
                sp.TenHamLogin = tenhamlogin;
                sp.TenHamTranfer = tenhamTranfer;
                sp.TenNhaMoGioi = tenNhaMoGioi;
                sp.TenService = tenservice;
                table.InsertOnSubmit(sp);
                table.Context.SubmitChanges();
                kq = 1;
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return kq;

        }
    }
}